package com.wn.consumer;

import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @author yellow Docter
 * @date 2023 -02-28
 * @desc
 */
@Component
public class MQ01Consumer {

    /**
     * 监听消息
     * @param msg
     * RabbitListener 监听消息 指定队列信息就可以
     * queuesToDeclare    如果队列不存在就创建队列
     *      @Queue 队列注解
     *         name = "queue-hello"  队列的名称
     */
    @RabbitListener(queuesToDeclare = @Queue(name = "queue-hello"))
    public void handlerMsg(String msg){
        System.out.println("消费者消息了:  " + msg);
    }

}
